#ifndef HERM_BASE_MD5_H
#define HERM_BASE_MD5_H

#include <string>
#include "herm/export_symbols.h"

namespace herm{

typedef unsigned char md5_byte_t; /* 8-bit byte */
typedef unsigned int md5_word_t; /* 32-bit word */

/* Define the state of the MD5 Algorithm. */
struct MD5State 
{
    md5_word_t count[2];	/* message length in bits, lsw first */
    md5_word_t abcd[4];		/* digest buffer */
    md5_byte_t buf[64];		/* accumulate block */
};

/* Initialize the algorithm. */
void HERM_API MD5Init(MD5State *pms);

/* Append a string to the message. */
void HERM_API MD5Append(MD5State *pms, const md5_byte_t* data, int nbytes);

/* Finish the message and return the digest. */
void HERM_API MD5Finish(MD5State *pms, md5_byte_t digest[16]);

class HERM_API MD5Generator
{
public:
    MD5Generator();
    void Append(const std::string& data);
    std::string Finish();
    std::string FinishHex();
private:
    MD5State m_state;
};
}

#endif 
